package com.maochang.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.maochang.mapper.PsSolvetaskMainMapper;
import com.maochang.pojo.*;
import com.maochang.pojo.util.Result;
import com.maochang.pojo.util.Result1;
import com.maochang.service.PsInSpectiontaskDetailService;
import com.maochang.service.PsSystemConfigService;
import com.maochang.service.XiaoQueRenWuZhiXingService;
import com.maochang.service.xiaoQuZhiDingService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("/XiaoQueHuiZhi")
public class XiaoQueRenWuHuiZhi {

    @Resource
    private XiaoQueRenWuZhiXingService xiaoQueRenWuZhiXingService;
    @Resource
    private PsSolvetaskMainMapper psSolvetaskMainMapper;
    @Resource
    private PsSystemConfigService PsSysTemConfigImpl;
    @Resource
    private xiaoQuZhiDingService xiaoQuZhiDingImpl;
    @Resource
    private PsInSpectiontaskDetailService PsInSpectiontaskDetailImpl;
    /**
     * 分页加查询
     * */
    @GetMapping("/XiaoQueCha")
    public Result1 ChaJson(PsSolvetaskMain aa, String kai, String jie, @RequestParam("page") int current, @RequestParam("limit") int size,HttpSession httpSession){
        Page<PsSolvetaskMain> PsInList= xiaoQueRenWuZhiXingService.ChaXjZhiXing(aa,kai,jie,current,size,httpSession);
        return Result1.success1(PsInList);
    }

    /**
     * 工作单据下拉框
     * */
    @GetMapping("/ChaGongDan")
    public List<PsSystemconfig> ChaXia(){
        return xiaoQueRenWuZhiXingService.ChaGongDan();
    }

    /**
     * 查询PSinspectiontaskmain中的相匹配的任务编号
     * */
    @GetMapping("/ChaRenBian")
    public PsInspectiontaskMain ChaRenBian(String solveTaskCode){
        return xiaoQueRenWuZhiXingService.ChaZiTask(solveTaskCode);
    }

    /**
     * 根据上面差到的任务编号id查询子表中的数据
     * */
    @GetMapping("/ChaRenBianZiShu")
    public List<PsInspectiontaskDetail> ChaRenBian(Integer id){
        return xiaoQueRenWuZhiXingService.ChaZiTaskId(id);
    }

    /**
     * 执行死值修改状态
     * */
    @PostMapping("/ZhiSiXiuZhuang")
    public Result ZhiSiXiuZhuang(PsSolvetaskMain id){
        xiaoQueRenWuZhiXingService.ZhiSiZhiXiu(id);
        return Result.success("修改成功");
    }
    /**
     * 根据id查询子表中的数据
     * */
    @GetMapping("/ChaQueZiShu")
    public List<PsSolvetaskDetail> ChaQueZiShu(Integer id){
        return xiaoQueRenWuZhiXingService.ChaQueZiShu(id);
    }

    /**
     * 根据子表中的inspectionTaskDelId查询巡检子表中的数据
     * */
    @GetMapping("/ChaXunZi")
    public List<PsInspectiontaskDetail> ChaXunZi(Integer[] id){
        return xiaoQueRenWuZhiXingService.ChaXunZi(id);
    }

    /**
     *
     */
    @GetMapping("/ChaRenBianZiShu1")
    public Result1 ChaJson2(PsSolvetaskMain aa, String kai, String jie, @RequestParam("page") int current, @RequestParam("limit") int size, HttpSession s){
        Page<PsSolvetaskMain> PsInList= xiaoQuZhiDingImpl.CHaXunZiRenWu( aa,current,size,kai,jie,s);
        return Result1.success1(PsInList);
    }
    @GetMapping("/chaRenWuZhuangTai")
    public List<PsSystemconfig>  chaRenWuZhuangTai(){
        List<PsSystemconfig> PsInList= PsSysTemConfigImpl.ChaQUeType();
        return PsInList;
    }
    @GetMapping("/DanJuLeiXIng")
    public List<PsSystemconfig>  DanJuLeiXIng(){
        List<PsSystemconfig> PsInList= PsSysTemConfigImpl.DanJuLeiXIng();
        return PsInList;
    }
    @GetMapping("/ChaXunJianZiRenWUQuXianXinXi")
    public Result1  QuXianXiXi(@RequestParam("page") int page, @RequestParam("limit") int size){
        Page<PsInspectiontaskDetail> psInspectiontaskDetailPage = PsInSpectiontaskDetailImpl.chaZiRenWu(page,size);
        return Result1.success1(psInspectiontaskDetailPage);
    }
}
